/* eslint-disable */
import { Button, Toast, Swiper, SwiperItem } from "mand-mobile";
import store from "@/tools/factory"
import { config } from "@/api/config"
import * as Request from '@/api/liubike';
import tools from "@/tools/index";
let that = null;

export default {
    name: "bill",
    data() {
        return {
            indicatorDots: false,
            vertical: false,
            autoplay: true,
            interval: 2000,
            duration: 500,
            submitStatus: false,
            settlementTypeText: "",
            successPayment: 0, // 行程总费用
            paymentFee: 0, // 行程花费费用
            activitymoney: 0, // 活动优惠金额
            couponMoney: 0, // 优惠金额
            drivingTime: {}, // 骑行时间
            ridingSecond: {}, // 计费时间
            myWallet: 0, // 我的钱包
            giveMoney: 0,
            outFenceMoney: 0,
            distance: 0,
            giveMoneyReward: 0,
            cashReward: 0,
            detailShow: false,
            billInfo: 0,
            customNo: "",
            billTitle: "",
            orderNo: "",
            popupIframe: false,
            showCancel: false,
            successHidden: true,
            needParkingImgReport: false,
            uploadStatus: false,
            phoneAngle: "",
            helmetMoney: "",
            dialogContent: {},
            guideContext: {},
            status: null,
            isHidden: true,
            showCancel: true,
            dialogContentShow: false,
            bannerList: [],
            dialogList: [],
            dialogShow: false,
            remainder: 0,
        };
    },
    components: {
        [Button.name]: Button,
        [Toast.name]: Toast,
        [Swiper.name]: Swiper,
        [SwiperItem.name]: SwiperItem
    },
    methods: {
        returnIndex() {
            this.$router.back(-1);
        },
        goRecharge() {
            this.$router.replace({
                name: "recharge"
            })
        },
        goRule() {
            store.set("wxWeb", "https://h5n.xlgxapp.com/user/help.html&&id=27&&article=true")
            this.$router.push({
                name: "webview"
            })
        },
        openModal() {

        },
        transferTime(intervalTime) {
            if (!intervalTime) {
                return false
            }
            // 计算出相差天数
            let days = Math.floor(intervalTime / (24 * 3600));
            // 计算出小时数
            let leave1 = intervalTime % (24 * 3600) // 计算天数后剩余的毫秒数
            let hours = Math.floor(leave1 / 3600)
            // 计算相差分钟数
            let leave2 = leave1 % 3600 //计算小时数后剩余的毫秒数
            let min = Math.floor(leave2 / 60)
            // 计算相差秒数
            let leave3 = leave2 % 60 //计算分钟数后剩余的毫秒数
            let sec = Math.round(leave3);
            // 使用时间 天/时/分/秒
            return { days: days, hours: hours, min: min, sec: sec }
        },
        getPayDetail(orderNo, fn) {
            // 支付账单信息
            Request.orderRiding({
                orderNo: orderNo
            }).then(res => {
                if (res.success) {
                    const orderRes = res.data;
                    that.drivingTime = that.transferTime(orderRes.bikeSecond);
                    that.ridingSecond = that.transferTime(orderRes.ridingSecond);
                    that.successPayment = (Number(orderRes.payMoney) + Number(orderRes.returnMoney) + Number(orderRes.giveMoney)).toFixed(2);
                    that.paymentFee = orderRes.money || 0;
                    that.cashReward = orderRes.cashReward;
                    that.outFenceMoney = orderRes.outFenceMoney;
                    that.giveMoneyReward = orderRes.giveMoneyReward;
                    that.couponMoney = Number(orderRes.couponMoney) || 0;
                    that.activitymoney = Number(orderRes.activityMoney) || 0;
                    that.distance = (orderRes.distance / 1000).toFixed(2) || 0;
                    that.billInfo = orderRes.billInfo;
                    that.billTitle = orderRes.billTitle;
                    that.orderNo = orderRes.orderNo;
                    that.status = orderRes.status;
                    that.customNo = orderRes.customNo;
                    that.settlementTypeText = orderRes.settlementTypeText;
                    that.helmetMoney = orderRes.helmetMoney;
                    that.needParkingImgReport = orderRes.needParkingImgReport;
                }
                fn && fn()
            });
        },
        quickPaySettingGuide() {

        }
    },
    created() {
    },
    mounted() {
        that = this;
        // 行程总费用
        let orderNo = this.$route.query.orderNo;
        // 客服强制结单
        if (store.get("failNum")) {
            store.remove("failNum");
        }
        that.getPayDetail(orderNo, function () {
            // that.quickPaySettingGuide();
        })
    }
};